export const loginRules = {
  // 变量名字和要el-form-item的prop属性值要一致
  // trigger 用于指定触发校验的时机，submit 表示只在提交表单时触发
  // Type  类型  关于校验邮箱以及其他的时候 ELement 使用的是 async-validator  (https://github.com/yiminghe/async-validator)
  userName: [{
    required: true,
    message: '请输入账号',
    trigger: 'blur'
  }, // 正则校验  必须是字母或者数字
  {
    pattern: /^[a-zA-Z0-9]+$/,
    message: '账号必须是字母或数字',
    trigger: 'blur'
  },
  {
    min: 5,
    max: 12,
    message: '账号长度在 5 到 12 个字符',
    trigger: 'blur'
  }

  ],
  passWord: [{
    required: true,
    message: '请输入密码',
    trigger: 'blur'
  }, {
    pattern: /^[a-zA-Z0-9]+$/,
    message: '密码必须是字母或数字',
    trigger: 'blur'
  },
  {
    min: 5,
    max: 12,
    message: '密码长度在 5 到 12 个字符',
    trigger: 'blur'
  }

  ]
}

export const registerRules = {
  // 注册表单验证规则
  userName: [{
    required: true,
    message: '请输入账号',
    trigger: 'blur'
  }, {
    pattern: /^[a-zA-Z0-9]+$/,
    message: '账号必须是字母或数字',
    trigger: 'blur'
  },
  {
    min: 5,
    max: 12,
    message: '账号长度在 5 到 12 个字符',
    trigger: 'blur'
  }
  ],
  passWord: [{
    required: true,
    message: '请输入密码',
    trigger: 'blur'
  }, {
    pattern: /^[a-zA-Z0-9]+$/,
    message: '密码必须是字母或数字',
    trigger: 'blur'
  },
  {
    min: 5,
    max: 12,
    message: '密码长度在 5 到 12 个字符',
    trigger: 'blur'
  }
  ],
  confirmPassword: [{
    required: true,
    message: '请确认密码',
    trigger: 'blur'
  }, {
    validator: (rule, value, callback) => {
      if (!value) {
        callback()
        return
      }
      // 获取表单实例来访问密码字段
      const form = rule.field ? rule.field.split('.')[0] : null
      if (form && form.passWord) {
        if (value !== form.passWord) {
          callback(new Error('两次输入的密码不一致'))
        } else {
          callback()
        }
      } else {
        // 如果无法获取密码字段，跳过验证
        callback()
      }
    },
    trigger: 'blur'
  }]
}
export const tableData = [
  { brands: '数字经济系', todayPurchases: 2999, monthPurchases: 130, totalPurchases: 2800 },
  { brands: '会计系', todayPurchases: 2500, monthPurchases: 120, totalPurchases: 1850 },
  { brands: '外语系', todayPurchases: 1800, monthPurchases: 90, totalPurchases: 1680 },
  { brands: '法学系', todayPurchases: 1620, monthPurchases: 100, totalPurchases: 1400 }

]

export const experienceInfo = [
  { title: '今日总签到', value: 8888, icon: 'User' },
  { title: '本月总签到', value: 99999, icon: 'User' },
  { title: '今日新增活动', value: 99, icon: 'User' },
  { title: '本月新增活动', value: 999, icon: 'User' },
  { title: '总活动数', value: 9999, icon: 'User' },
  { title: '总学生', value: 12000, icon: 'User' }
]
export const chartData = {
  title: {
    text: '今日系部签到数据'
  },
  xAxis: {
    data: tableData.map((item) => item.brands)
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: tableData.map((item) => item.todayPurchases),
      type: 'bar'
    }
  ]
}

